﻿// News Framework
// (C) Tanzim Saqib. Oct 25, 2010.
// http://TanzimSaqib.com | http://newsfx.codeplex.com

namespace TanzimSaqib.NewsFramework
{
    using System.Windows.Media;
    using System.ComponentModel;

    public class ViewModelBase : INotifyPropertyChanged
    {
        public event PropertyChangedEventHandler PropertyChanged;

        public void RaisePropertyChanged(string PropertyName)
        {
            var e = new PropertyChangedEventArgs(PropertyName);
            PropertyChangedEventHandler changed = PropertyChanged;
            if (changed != null) changed(this, e);
        }

        private string _PageTitle;
        public string PageTitle
        {
            get { return _PageTitle; }

            private set
            {
                _PageTitle = value;
                RaisePropertyChanged("PageTitle");
            }
        }

        private ImageBrush _BackgroundImageSource;
        protected ImageBrush BackgroundImageSource
        {
            get { return _BackgroundImageSource; }

            set
            {
                _BackgroundImageSource = value;
                RaisePropertyChanged("BackgroundImageSource");
            }
        }

        public ViewModelBase()
        {
            if(!Fx.IsDesignMode)
            {
                PageTitle = Fx.Instance.Settings[FxConstants.AppTitle];
                Fx.Instance.RootFrame.Background = BackgroundImageSource = PhoneUI.GetBackgroundBrush();
            }
        }
    }
}
